<?PHP
require_once WACT_ROOT.'controller/controller.inc.php';
require_once APP_ROOT.'view/pub/layoutright.view.php';
require_once APP_ROOT.'model/common/session.php';
require_once APP_ROOT.'model/common/user.php';
require_once APP_ROOT.'model/common/team.php';
require_once APP_ROOT.'model/common/date.php';
require_once APP_ROOT . "model/common/site.php";


class TeamsPrintDetailView extends View {
	function TeamsPrintDetailView($TemplateFile){
		parent::View($TemplateFile);

	}

	function prepare(&$controller, &$request, &$responseModel){
		parent::prepare(&$controller, &$request, &$responseModel);
		$docbase="http://".$_SERVER['HTTP_HOST'];
		$this->Template->set('docbase',$docbase);

        
		$this->Template->set('SITE_CSS',Site::getSiteTemplateCSS());
		$this->Template->set('SITE_BASE',Site::getSiteTemplateBase());
		$this->Template->set('SITE_TITLE',Site::getTitle());
		$this->Template->set('title',Site::getTitle().' - ');


		$team_id=$request->getParameter('id');

		$this->Template->set('team_id',$team_id);

		$team=&Team::getRecord($team_id);

		if(Session::isLogin()&&Session::getUserId()==$team->get('user_id'))
			$this->Template->set('author',' ');

        $city = Site::getTitle();
		$this->Template->set('title',$city.'- Team profile - '.$team->get('name'));

		$datestr=$team->get('date_added');
		$mydate = strtotime($datestr);
        $tz =& new MyTimeZone();
        $mydate = $tz->timeGMT($mydate);
		$datestr = gmstrftime('%b %d, %Y',$mydate);
		$this->Template->set('date_added',$datestr);

		$prem=$team->get('premium');
		if($prem&&$prem==0) $prem=null;
		$this->Template->set('prem',$prem);

		$this->Template->set('name',$team->get('name'));

		$gender=$team->get('league_gender');
		if($gender==1) $gender='girls';
		else $gender='boys';
		$this->Template->set('gender',$gender);

		$league=&Team::getLeagueName($team->get('league'));
		$this->Template->set('league',$league);

		$colors=$team->get('colors');
		if($colors) $this->Template->set('colors',$colors);

		$category1=$team->get('category1');
		$category2=$team->get('category2');

		//categories
		if($category1) {
			$category=$category1;
			if($category2)	$category.='/'.$category2;
			$this->Template->set('category',$category);
		} else if($category2){
			$this->Template->set('category',$category2);
		}



		//school
		$school=$team->get('school_name');
		if($school)$this->Template->set('school_name',$school);

		$location=null;
		$saddress=$team->get('school_address');
		$scity=$team->get('school_city');
		$sstate=$team->get('school_state');
		$szip=$team->get('school_zip');
		$sphone=$team->get('school_phone');
		if($saddress) {
			$this->Template->set('school_address',$saddress);
			$location=' ';
		}
		if($scity) $location=$scity;
		if($sstate&&$sstate!='(N') $location.=', '.$sstate;
		if($szip) $location.=' '.$szip;
		if($location&&$location!=' ')
			$this->Template->set('school_lastaddress',$location);
		if($sphone) {
			$location='Phone: '.$sphone;
			$this->Template->set('school_phone',$location);
		}
		if($location)$this->Template->set('school_location',true);

		//coach

		$coach_name=$team->get('coach_name');
		$coach_phone=$team->get('coach_phone');
		if($coach_name){
			$coach=$coach_name;
			if($coach_phone) 	$coach.=', '.$coach_phone;
			$this->Template->set('coach',$coach);
		}

		$coach_info=$team->get('coach_info');
		$this->Template->set('coach_info',$coach_info);


		$top_players=$team->get('top_players');
		if($top_players&&$top_players!='')
			$this->Template->set('top_players',$top_players);

		$players_in=$team->get('players_in');
		if($players_in&&$players_in!='')
			$this->Template->set('players_in',$players_in);

		$players_out=$team->get('players_out');
		if($players_out&& $players_out!='')
			$this->Template->set('players_out',$players_out);

		$schedule=$team->get('schedule');
		if($schedule&& $schedule!='')
			$this->Template->set('schedule',$schedule);

		$other=$team->get('other');
		if($other&& $other!='')
			$this->Template->set('other',$other);


		if(APP_NAME!=""){
			$this->Template->set('app_name',HOST."/".APP_NAME);
		} else $this->Template->set('app_name',HOST);


	}

}



class TeamsPrintDetailPage extends PageController {
	function TeamsPrintDetailPage() {
		parent::PageController();
        $site_id = Site::getTemplateSiteID();
        $mytemplate1 = 'pub/teams/print_teaser.html';
        
		$this->setDefaultView(new TeamsPrintDetailView($mytemplate1));

	}

}




?>
